/* 
 *	Copyright (C) 2009-2010 miaohua
 *	http://code.google.com/p/lrcshower/
 *
 *  This Program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2, or (at your option)
 *  any later version.
 *   
 *  This Program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 *  GNU General Public License for more details.
 *   
 *  You should have received a copy of the GNU General Public License
 *  along with GNU Make; see the file COPYING.  If not, write to
 *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 
 *  http://www.gnu.org/copyleft/gpl.html
 *
 */
#pragma once

class CColorButton : public CButton
{
    
public:
    // Construction
	CColorButton(COLORREF * Clrs, int ClrNum);
	~CColorButton();

protected:
	// Message handlers
	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
	afx_msg LRESULT OnMouseLeave(WPARAM wParam, LPARAM lParam);
	afx_msg LRESULT OnMouseHover(WPARAM wParam, LPARAM lParam);
	afx_msg void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);

	DECLARE_MESSAGE_MAP()
private:
    // Helper functions
    // Draw the background of button
	void DoGradientFill(CDC *pDC, const CRect & Rect);
    // Draw button's inner rectangle
	void DrawInsideBorder(CDC *pDC, const CRect & Rect);

    // Attributes
    // Pen for button's outline
	CPen m_BoundryPen;                            
	
	// Pens for button inner boundry when mouse hang over
	CPen m_InsideBoundryPenLeft;
	CPen m_InsideBoundryPenRight;
	CPen m_InsideBoundryPenTop;
	CPen m_InsideBoundryPenBottom;
	
	// Pens for button inner boundry when focus
	CPen m_InsideBoundryPenLeftSel;
	CPen m_InsideBoundryPenRightSel;
	CPen m_InsideBoundryPenTopSel;
	CPen m_InsideBoundryPenBottomSel;
	
	// Background color active or in active
	CBrush m_FillActive;
	CBrush m_FillInactive;
	
	// State of button
	BOOL m_IsHangOver;	             // When mouse is hanging over button, it is true,otherwise false
	BOOL m_IsTracking;	             // When mouse's left button is down and not be released, it is true, otherwise false
	BOOL m_IsSelected;	             // When button is pushed down, it is true, otherwise it is false
	BOOL m_IsFocus;	                 // When buuton is focused, it is true, otherwise it is false
    
    // Draw data
    COLORREF * m_Clrs;               // Colors to be painted on
    int m_ClrNum;                    // Number of colors
};